//练习1
const fp = require('lodash/fp')
const {Maybe, Container} = require('./support')
let maybe = Maybe.of([5,6,1])
let ex1 = (value)=> {
    let addValue = fp.map(fp.add(value))
    return maybe.map(x => addValue(x))
}
// 增加1
console.log(ex1(1))  


//练习二
let xs = Container.of(['do','ray','me','fa','so','la','ti','do'])
let ex2 = ()=> {
    return xs.map(x => fp.first(x))
}
console.log(ex2()) 

//练习三
let sefeProp = fp.curry(function(x, o) {
    return Maybe.of(o[x])
})
let user = {id: 2, name: 'Albert'}
let ex3 = () => {
    let findFirst = sefeProp('name',user).map(x => fp.first(x))
    console.log(findFirst)
}
ex3()

//练习4
let ex4 = function(n) {
    Maybe.of(n).map(x => parseInt(x))
    // if(n) {
    //     return parseInt(n)
    // }
}
